package org.jianghu.activity.user.forgot;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import org.jianghu.R;
import org.jianghu.base.BaseActivity;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by Administrator on 2016/12/23.
 */
@ContentView(R.layout.activity_forgot)
public class ForgotActivity extends BaseActivity{

    @ViewInject(R.id.btn_send_yzm)
    private Button btn_send_yzm;

    @ViewInject(R.id.edt_forgot)
    private EditText edt_forgot;

    @ViewInject(R.id.btn_close)
    private ImageView img_close;
    TextWatcher textWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (!TextUtils.isEmpty(edt_forgot.getText().toString())){
                btn_send_yzm.setEnabled(true);
                btn_send_yzm.setBackgroundColor(getResources().getColor(R.color.color_2095f2));
            }else{
                btn_send_yzm.setEnabled(false);
                btn_send_yzm.setBackgroundColor(getResources().getColor(R.color.hui_68));
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    };

    @Override
    public void initViewsAndValues(Bundle savedInstanceState) {
        x.view().inject(this);
        editWatcher();
    }

    @Override
    public void initParmers() {

    }

    @Override
    public void releaseOnDestory() {

    }

    @Event(value = {R.id.btn_send_yzm,R.id.btn_close})
    private void onclickListner(View view){
        switch (view.getId()){
            case R.id.btn_send_yzm:

                break;

            case R.id.btn_close:
                finish();
                break;
        }
    }

    private void editWatcher(){
        edt_forgot.addTextChangedListener(textWatcher);
    }
}
